package com.xiaotu.web.struts2.blog;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionSupport;
import com.xiaotu.code.model.blog.Blog;
import com.xiaotu.code.service.blog.BlogService;
/**
 * blog.
 * @author chenxiangrong
 *
 */
@Results({@Result(name="blogMain",location="/WEB-INF/content/blog/queryMain.jsp"),
	@Result(name="bloglist",location="/WEB-INF/content/blog/queryResult.jsp")})
public class BlogAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = -518633960984631283L;
	private String queryKey;
	private List<Blog> blogList;
	@Autowired
	private BlogService blogService;
	
	@Action("/blog/queryMain")
	public String queryMain()throws Exception{
		return "blogMain";
	}
	
	@Action("/blog/query")
	public String queryBlogs()throws Exception{
		blogList=this.blogService.queryBlogByKey(queryKey);
		return "bloglist";
	}
	
	public String getQueryKey() {
		return queryKey;
	}
	public void setQueryKey(String queryKey) {
		this.queryKey = queryKey;
	}
	public List<Blog> getBlogList() {
		return blogList;
	}
	public void setBlogList(List<Blog> blogList) {
		this.blogList = blogList;
	}

}
